import java.util.Arrays;

public class Homework {
    public String method(String s){
        int len = s.length();
        int[] arr = new int['z' - 'A' + 1];
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < len; i++) {
            char ch = s.charAt(i);
            arr[ch - 'A']++;
        }
        for (int i = 0; i < len; i++) {
            char ch = s.charAt(i);
            if(arr[ch - 'A'] > 0){
                stringBuilder.append(ch);
                arr[ch - 'A'] = 0;
            }
        }
        return stringBuilder.toString();
    }
    public String method2(String s){
        int len = s.length();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < len; i++) {
            char ch = s.charAt(i);
            if(stringBuilder.indexOf(ch + "") < 0){
                stringBuilder.append(ch);
            }
        }
        return stringBuilder.toString();
    }

    //合并有序数组
    public int[] merge (int[] nums1, int m, int[] nums2, int n) {
        for(int i = m; i < m+n; i++){
            nums1[i] = nums2[i -m];
        }
        Arrays.sort(nums1);
        return nums1;
    }
    public int[] merge2 (int[] nums1, int m, int[] nums2, int n) {
        int k = m + n - 1;
        int i = m - 1;
        int j = n - 1;
        while(i >= 0 && j >= 0){
            if(nums1[i] >= nums2[j]){
                nums1[k] = nums1[i];
                i--;
            }else{
                nums1[k] = nums2[j];
                j--;
            }
            k--;
        }
        while(i > 0){
            nums1[k] = nums1[i];
            k--;
            i--;
        }
        while(j > 0){
            nums1[k] = nums2[j];
            k--;
            j--;
        }

        return nums1;
    }
    public static void main(String[] args) {
        Homework homework = new Homework();
        String s = "BAabB";
        //s = main.method(s);
        s = homework.method2(s);
        System.out.println(s);
    }
}